﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using GoShopping.Model;
using System.Collections.Generic;
using GoShopping.BLL;
using GoShopping.Model.CustomDefine;
using GoShopping.Utility;
using GoShopping.BLL.Orders;
using GoShopping.Model.Enumerations;

namespace Test
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GoShopping.BLL.Databases.DebugSql();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.MemberShipService m = new GoShopping.BLL.MemberShipService();
            bool b =m.ValidateUser("go_shopping2009", "goshopping");
            Response.Write(b);
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.MemberShipService m = new GoShopping.BLL.MemberShipService();
            this.GridView1.DataSource = m.GetAllMembers();
            this.GridView1.DataBind();
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.MemberShipService m = new GoShopping.BLL.MemberShipService();
            bool b = m.IsUserInMembershipDB("go_shopping2009");
            Response.Write(b);
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.UserBean m = new GoShopping.BLL.UserBean();
            this.GridView1.DataSource = m.GetAllUserList();
            this.GridView1.DataBind();
        }

        protected void Button5_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.EmailTempleteBean m = new GoShopping.BLL.EmailTempleteBean();
            this.GridView1.DataSource = m.GetAllEmailTemplete();
            this.GridView1.DataBind();
        }

        protected void Button6_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.EmailTempleteBean m = new GoShopping.BLL.EmailTempleteBean();
            EmailTemplete em=new EmailTemplete();
            em.ConfigExplain="邮件说明";
            em.ContentHTML="<a>a</a>";
            em.EmailTitle="标题";
            em.IsInUse=true;
            bool b = m.UpdateEmailTemplete(em, GoShopping.Model.Enumerations.EmailTempleteType.UserRegist);
            Response.Write(b);
        }

        protected void Button7_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.MemberShipService m = new GoShopping.BLL.MemberShipService();
            MembershipCreateStatus statue;
            bool b = m.CreateMember("user", "lvjm@163.com", "user", "qst", "user", true, GoShopping.Model.Enumerations.Member_Roles.Role_Member, out statue);
            Response.Write(b);
        }

        protected void Button8_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.MemberShipService m = new GoShopping.BLL.MemberShipService();
            IList<GoShopping.Model.Enumerations.Member_Roles> r = m.GetMemberRoleList("user");
            Response.Write(r.ToString());
        }

        protected void Button9_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.SuperManagerBean m = new GoShopping.BLL.SuperManagerBean();
            //Response.Write(m.CustomSQL());
        }

        protected void Button10_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.ProductTypeBean b = new GoShopping.BLL.ProductTypeBean();

            //IList<ProductType> list = b.GetAllProductTypeList();
            //foreach (ProductType t in list)
            //{
            //    b.DelProductType(t);
            //}

            ProductType t = new ProductType();
            t.ParentID = -1;
            t.Remark = "qwe";
            t.TypeName = "数码相机";
            bool b1 = b.AddProductType(t);

            t.ParentID = 1;
            t.TypeName = "佳能";
            bool b2 = b.AddProductType(t);
            Response.Write(b2);
        }

        protected void Button11_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.ProductTypeBean b = new GoShopping.BLL.ProductTypeBean();
            this.GridView1.DataSource = b.GetAllProductTypeList();
            this.GridView1.DataBind();
        }

        protected void Button12_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.ProductTypeBean b1 = new GoShopping.BLL.ProductTypeBean();
            bool b = b1.DelProductType(1);
            Response.Write(b);
        }

        protected void Button13_Click(object sender, EventArgs e)
        {
            ProductTypeBean tb = new ProductTypeBean();
            GoShopping.Model.CustomDefine.ProductTypeProperty property = new GoShopping.Model.CustomDefine.ProductTypeProperty();
            property.ProdyctTypeID = 6;
            property.PropertyName = "容量";
            property.ValueType = GoShopping.Model.Enumerations.PropertyValueType.字符;
            bool b = tb.AddProductTypeProperty(property);
            Response.Write(b);
        }

        protected void Button14_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.ProductTypeBean b1 = new GoShopping.BLL.ProductTypeBean();
            bool b = b1.DelProductTypeProperty(6,"容量");
            Response.Write(b);
        }

        protected void Button15_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.ProductTypeBean b1 = new GoShopping.BLL.ProductTypeBean();
            IList<ProductTypeProperty> list = b1.GetProductTypeProperties(6);
            this.GridView1.DataSource = list;
            this.GridView1.DataBind();
        }

        protected void Button16_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.ProductSuplyBean sp = new ProductSuplyBean();
            GoShopping.Model.PrdctSupplyer s = new PrdctSupplyer();
            s.Address = "beijing";
            s.Name = "ICT";
            s.Telephone = "01022235454";
            s.CompanyFullName = "sdfasfasdf"; ;
            sp.AddPrdctSuply(s);
            //sp.UpdatePrdctSuply

            GoShopping.BLL.ProductBean pb = new ProductBean();
            Product p = new Product();
            p.Brand = "联想";
            p.BriefIntroduction = "asfasdfasdf";
            p.Name = "联想MP3";
            p.ProductTypeID = 4;
            p.SupplyerID = 1;
            int b = pb.AddProductBase(p);
            Response.Write(b);
        }
        protected void Button17_Click(object sender, EventArgs e)
        {
            ProductImgBean.GetProductImgPath(1, 1);
        }
        protected void Button18_Click(object sender, EventArgs e)
        {
            ProductImgBean.SetProductImage(1, 1,this.FileUpload1);
        }
        protected void Button19_Click(object sender, EventArgs e)
        {
            string s = ProductImgBean.GetProductImgPath(1, 1);
            s = WebPath.ConvertSpecifiedPathToRelativePath(this, s);
            Console.WriteLine(s);
            OrderBean ob = new OrderBean();
            s = ob.CreateOrderCode(1);
        }
        protected void Button20_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.PrdctInfo.ExcelHelper el = new GoShopping.BLL.PrdctInfo.ExcelHelper();
            el.ExportTemplate(this);
        }
        protected void Button21_Click(object sender, EventArgs e)
        {
            GoShopping.BLL.PrdctInfo.ExcelHelper eh = new GoShopping.BLL.PrdctInfo.ExcelHelper();
            eh.ImportResult(this, this.FileUpload2);
        }
        protected void Button22_Click(object sender, EventArgs e)
        {
            this.Button22.Text = GoShopping.Utility.EnumBoundings.OptionEnum.GetEnumDescription(
                typeof(EmailTempleteType), EmailTempleteType.ChangePassWord.ToString());
        }
}
}
